package com.powerbridge.example.config;

import org.springframework.stereotype.Component;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;

/**
 * @Description: apollo配置信息注入
 * @author: shunhe@powerbridge.com
 * @Date: 2017年11月20日上午10:14:07
 */
@Component("exampleConfig")
@org.springframework.cloud.context.config.annotation.RefreshScope
public class ExampleConfig {

	@ApolloConfig
	private Config config;

	public int getPort() {
		return config.getIntProperty("server.port", 8080);
	}
	
	public String getSpringProfilesActive() {
		return config.getProperty("spring.profiles.active", "dev");
	}
	
	public String getProfiles() {
		return config.getProperty("spring.profiles", "dev");
	}
	
	public String getDataSourceUrl() {
		return config.getProperty("spring.datasource.url", "");
	}
	
	public String getDataSourceUsername() {
		return config.getProperty("spring.datasource.username", "root");
	}
	
	public String getDataSourcePassword() {
		return config.getProperty("spring.datasource.password", "qwe456");
	}
	
	public String getDataSourceTestWhileIdle() {
		return config.getProperty("spring.datasource.test-while-idle", "true");
	}
	
	public String getDataSourceValidationQuery() {
		return config.getProperty("spring.datasource.validation-query", "SELECT 1");
	}
	
	public int getRedisDatabase() {
		return config.getIntProperty("spring.redis.database", 0);
	}
	
	public String getRedisHost() {
		return config.getProperty("spring.redis.host", "172.16.0.168");
	}
	
	public int getRedisPort() {
		return config.getIntProperty("spring.redis.port", 6379);
	}
	
	public String getRedisPassword() {
		return config.getProperty("spring.redis.password", "1");
	}
	
	public String getRedisTimeout() {
		return config.getProperty("spring.redis.timeout", "0");
	}
	
	public int getRedisPoolMaxActive() {
		return config.getIntProperty("spring.redis.pool.max-active", 300);
	}
	
	public int getRedisPoolMaxWait() {
		return config.getIntProperty("spring.redis.pool.max-wait", 10000);
	}
	
	public int getRedisPoolMaxIdle() {
		return config.getIntProperty("spring.redis.pool.max-idle", 8);
	}
	
	public int getRedisPoolMinIdle() {
		return config.getIntProperty("spring.redis.pool.min-idle", 0);
	}
	
	public String getApplicationName() {
		return config.getProperty("spring.application.name", "pbplatform-example");
	}
	
	public String getEurekaInstancePreferIpAddr() {
		return config.getProperty("eureka.instance.prefer-ip-address", "true");
	}
	
	public String getEurekaClinetServiceUrlDefaultZone() {
		return config.getProperty("eureka.client.serviceUrl.defaultZone", "http://10.88.0.69:8870/eureka");
	}
	
	public String getEndPointsHealthSensitive() {
		return config.getProperty("endpoints.health.sensitive", "false");
	}
	
	public String getEndPointsHealthEnabled() {
		return config.getProperty("endpoints.health.enabled", "true");
	}
	
	public String getEndPointsActuatorEnabled() {
		return config.getProperty("endpoints.actuator.enabled", "true");
	}
//	
//	public String getMyBatisBasePackage() {
//		return config.getProperty("mybatis.basepackage", "com.powerbridge.example.dao");
//	}
	
	public String getMyBatisXmlLocation() {
		return config.getProperty("mybatis.xmlLocation", "classpath:mapper/**/*.xml");
	}
	
	public String getLogginLevelComPowrebridge() {
		return config.getProperty("logging.level.com.powerbridge.example", "DEBUG");
	}
	
	public String getBatchA() {
		return config.getProperty("batch.a", "1000");
	}
	
	public String getBatchB() {
		return config.getProperty("batch.b", "2000");
	}
}

